package game.module.club.processor;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import game.common.PlayingRoleMsgProcessor;
import game.entity.PlayingRole;
import game.module.club.logic.ClubManager;
import lion.common.MsgCodeAnn;
import lion.netty4.message.MyRequestMessage;
import lion.netty4.message.RequestMessageRaw;
import lion.netty4.message.RequestProtoMessage;
import lua.LuaMessageHall.C2SClubUp;
import lua.LuaMessageHall.S2CClubUp;
import lua.LuaMessageLogin.S2ErrorCode;

/**
 * @author: Pomelo.Lee
 * @date: 2017年8月31日 下午3:50:14
 */
@MsgCodeAnn(msgcode = C2SClubUp.id, accessLimit = 500)
public class ClubUpProcessor extends PlayingRoleMsgProcessor {

	private static Logger logger = LoggerFactory.getLogger(ClubUpProcessor.class);

	@Override
	public void process(PlayingRole playingRole, RequestMessageRaw requestMessage) throws Exception {
		int playerId = playingRole.getId();
		logger.info("player club  up playerId={}", playerId);

		S2CClubUp respMsg = new S2CClubUp();
		int resp = ClubManager.getInstance().upClub(playingRole, respMsg);
		if (resp != 1) {
			S2ErrorCode retMsg = new S2ErrorCode(resp);
			playingRole.writeAndFlush(retMsg.build(playingRole.alloc()));
			return;
		}

		playingRole.writeAndFlush(respMsg.build(playingRole.alloc()));
	}

	@Override
	public void processProto(PlayingRole playingRole, RequestProtoMessage request) throws Exception {
		// TODO Auto-generated method stub

	}

	@Override
	public void processWebsocket(PlayingRole playingRole, MyRequestMessage request) throws Exception {
		// TODO Auto-generated method stub

	}

}
